package cn.edu.sgu.www.mhxysy.entity.chongwu;

import cn.edu.sgu.www.mhxysy.consts.IdentifierPrefixes;
import cn.edu.sgu.www.mhxysy.enums.NeidanTypes;
import cn.edu.sgu.www.mhxysy.exception.GlobalException;
import cn.edu.sgu.www.mhxysy.restful.ResponseCode;
import cn.edu.sgu.www.mhxysy.util.StringUtils;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;

/**
 * 宠物内丹
 * @author 沐雨橙风ιε
 * @version 1.0
 */
@Data
@ApiModel
@TableName("chongwu_neidan")
public class ChongwuNeidan implements Serializable {
	private static final long serialVersionUID = 18L;

	@TableId(value = "id", type = IdType.INPUT)
	@ApiModelProperty(value = "ID")
	private String id;

	/**
	 * 内丹类型
	 */
	@ApiModelProperty(value = "内丹类型")
	private Integer type;

	/**
	 * 内丹层数
	 */
	@ApiModelProperty(value = "内丹层数")
	private Integer grade;

	/**
	 * 领悟状态
	 * 0-未领悟；1-已领悟
	 */
	@ApiModelProperty(value = "领悟状态")
	private Integer comprehendStatus;

	/*
	 * 镶嵌位置
	 * 取值：0、1、2、3、4、5
	 * 高级内丹：0；低级内丹：1~4；专属内丹：5
	 */
	@ApiModelProperty(value = "镶嵌位置")
	private Integer location;

	/**
	 * 宠物ID
	 */
	@ApiModelProperty(value = "宠物ID")
	private String chongwuId;

	/**
	 * 内丹类型ID
	 */
	@ApiModelProperty(value = "内丹类型ID")
	private Integer neidanId;

	public String uuid(Integer type) {
		if (NeidanTypes.ZSND.getValue().equals(type)) {
			return IdentifierPrefixes.PREFIX_ZSND + StringUtils.uuid();
		} else if (NeidanTypes.DJND.getValue().equals(type) || NeidanTypes.GJND.getValue().equals(type)) {
			return IdentifierPrefixes.PREFIX_CWND + StringUtils.uuid();
		}

		throw new GlobalException(ResponseCode.BAD_REQUEST, "非法的内丹类型~");
	}

}